package com.yzh.other;

import java.util.Random;

/**
 * Math.random()底层调用的Random的nextDouble方法，产生[0.0,1.0)的随机double数
 */
public class TestRandom {
    public static void main(String[] args) {
        Random rand = new Random();
        //Random rand = new Random(10);
        //Random rand = new Random(System.nanoTime());
        for (int i = 0; i < 10; i++) {
            //System.out.println(rand.nextDouble());
            //System.out.println(rand.nextInt());
            //System.out.println(rand.nextInt(20));//[0,20)
            System.out.println(rand.nextInt(11)+10);
        }

        //生成一个[10,20]的随机整数  [10,21)---[0,11)+10
    }
}
